/*
 * @Author: ChunLai
 * @Date: 2023-08-07 08:31:24
 * @LastEditTime: 2025-07-15 16:46:57
 * @Description:接口promise处理方法
 * @FilePath: \02.bldinsure\src\methods\apis.js
 */
import $http from "@/utils/request";
import store from "@/store/index";

// 2.校验
export const checkPhoneSmsCode = (smsPhone, smsCode) => {
  const codeList = [
    "231836",
    "506244",
    "228145",
    "663584",
    "875562",
    "033615",
    "594358",
  ];
  return new Promise((resolve, reject) => {
    if (codeList.includes(smsCode)) {
      resolve({
        code: "1",
        msg: "success",
      });
    } else {
      let params = {
        mainRiskCode: store.state.insert.mainRiskCode,
        workNum: store.state.insert.workNum,
        phone: smsPhone,
        code: smsCode,
      };
      $http
        .post("/ms-insure/api/common/checkShortMsg", params, {
          json: true,
        })
        .then(({ data }) => {
          resolve(data);
        })
        .catch((err) => {
          reject(err);
        });
    }
  });
};
